package im.xz.cn.xiacore.menu.shopMenu;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
public class shopEvent implements Listener {
    @EventHandler
    public void qwq(InventoryClickEvent event) {
        try {
            if (event.getView().getTitle().equals(ChatColor.LIGHT_PURPLE + "繁星梦 - 商店")) {
                ItemStack click = event.getCurrentItem();
                Player player = (Player) event.getWhoClicked();
                try {
                    if (click.getType().equals(Material.BOOK)) {
                        player.closeInventory();
                        player.performCommand("plt open");
                    }else if (click.getType().equals(Material.SLIME_BALL)) {
                        player.closeInventory();
                        switch (click.getAmount()) {
                            case 1:
                                player.performCommand("rshop open onlySell");
                            case 2:
                                player.performCommand("rshop open daySell");
                        }
                    }else if (click.getType().equals(Material.MAGMA_CREAM)) {
                        player.closeInventory();
                        switch (click.getAmount()) {
                            case 1:
                                player.performCommand("rshop open onlyBuy");
                            case 2:
                                player.performCommand("rshop open dayBuy");
                        }
                    }else if (click.getType().equals(Material.BARRIER)) {
                        player.closeInventory();
                        player.performCommand("menu");
                    }
                }catch (NullPointerException ignore) {

                }
            }
        }catch (NullPointerException ignore) {

        }
    }
}